package com.cdc.bubblesort;

import java.util.Arrays;

public class BubbleSort {

	public static void main(String[] args) {
		int [] array=ArrayTool.initArray(5);
		System.out.println("排序前："+Arrays.toString(array));
		bubblesort(array);
		System.out.println("排序后："+Arrays.toString(array));

	}
	
	private static void bubblesort(int [] arr) {
		for (int i = 0; i < arr.length; i++) {
			for (int j = 0; j < arr.length-i-1; j++) {
				if(arr[j]>arr[j+1]) {
					int temp=arr[j];
					arr[j]=arr[j+1];
					arr[j+1]=temp;
				}
			}
		}
	}

}
